# encoding: utf-8
"""
@author: 夏洛
@QQ: 1972386194
@file: aa.py
"""
import requests
# url = 'https://api.waitwaitpay.com/api/voucher_suppliers'
import asyncio
import websockets
async def check_permit(websocket):
    for i in range(1, 3):
        key = '长沙'
        page = i
        url = f'https://api.waitwaitpay.com/api/vendors/nearby?keyword={key}&latitude&longitude&page={page}&request_id=b843a67b-98f7-4036-9ade-322503734244&type=search&with_vouchers=false'
        res = requests.get(url)
        send_text = res.text
        await websocket.send(send_text)
    return True

async def recv_msg(websocket):
    while 1:
        recv_text = await websocket.recv()
        print(recv_text)
async def main_logic(websocket, path):
    await check_permit(websocket)
    await recv_msg(websocket)

start_server = websockets.serve(main_logic, '127.0.0.1', 9999)
asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever()






#  在JS里面进行数据拦截    在使用websocket 与python 进行通讯
# 找加密位置

